package com.web.session.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.web.bdo.User;
import com.web.bdo.session.UserSession;

public class SessionUtil {

	public static void login(User user, HttpServletRequest request) {
		
		UserSession userSession = new UserSession(user, request);		
		request.getSession().setAttribute("user", user);
		request.getSession().setAttribute("session", userSession);
		request.getSession().setAttribute("authorized", true);		
	}
	
	
	public static boolean isLoggedIn(HttpSession session) {
		
		if (session.getAttribute("user")==null) {
			return false;
		}
		else {
			return true;
		}
	}
}
